<?php
abstract class AMS_Object {
    protected $data = array();
    public function __set($name, $value) {
        $this->data[$name] = $value;
    }
    public function __get($name) {
        if (array_key_exists($name,$this->data))
            return $this->data[$name];
    }
    public function __isset($name) {
        return isset($this->data[$name]);
    }
    public function __unset($name) {
        unset($this->data[$name]);
    }
    public function setData($key, $value=null) {
        if (!is_array($key))
            $this->data[$key] = $value;
        else $this->data = $key;
    }
    public function getData($key) {
        if (array_key_exists($key, $this->data)) return $this->data[$key];
    }
    public function __call($name, $arguments) {
        if (($get=(strpos($name,'get')===0)) || ($set=(strpos($name,'set')===0))) {
            $valueName = preg_replace('/([A-Z])/e','strtolower(\'_\\1\')',lcfirst(substr($name,3)));
            if ($get) return $this->__get($valueName);
            elseif ($set) {
                $this->__set($valueName,reset($arguments));
                return $this;
            }
        }
    }
}

?>
